import io from 'socket.io-client'

const socket = io()
let lineData = [9, 8, 7, 10, 12, 15, 13, 10, 11, 12, 14, 16]
let pieData = [
  { value: 400, name: 'Search Engine' },
  { value: 200, name: 'Direct' },
  { value: 100, name: 'Email' },
  { value: 100, name: 'Union Ads' },
  { value: 200, name: 'Video Ads' }
]
let radarData = [30000, 25000, 35000, 40000, 32000, 38000]

socket.on('connect', () => {
  console.log('服务器已经建立连接')
})

socket.on('disconnect', () => {
  console.log('服务器已经断开连接')
})

// 发送消息
// socket.emit('enter', 'admin')

// 接收消息
socket.on('line_data', (data) => {
  lineData = data
})

socket.on('pie_data', (data) => {
  pieData = data
})

socket.on('radar_data', (data) => {
  radarData = data
})

export { lineData, pieData, radarData }